package cn.huaqingcheng.tianshu.application.http;

import cn.huaqingcheng.tianshu.core.uc.model.BackgroundSetting;
import cn.huaqingcheng.tianshu.core.uc.model.GeneralSetting;
import cn.huaqingcheng.tianshu.core.uc.service.AccountSettingService;
import cn.huaqingcheng.tianshu.security.annotation.CurrentAccountId;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * AccountSettingController
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/account/setting")
public class AccountSettingController {

    private final AccountSettingService accountService;


    /**
     * 获取背景设置
     */
    @GetMapping("/background")
    public BackgroundSetting getBackgroundSetting(@CurrentAccountId Long accountId) {
        return accountService.getBackgroundSetting(accountId);
    }

    /**
     * 设置背景设置
     */
    @PutMapping("/background")
    public BackgroundSetting setBackgroundSetting(
            @CurrentAccountId Long accountId,
            @RequestBody BackgroundSetting setting
    ) {
        return accountService.setBackgroundSetting(accountId, setting);
    }

    /**
     * 获取通用设置
     */
    @GetMapping("/general")
    public GeneralSetting getGeneralSetting(@CurrentAccountId Long accountId) {
        return accountService.getGeneralSetting(accountId);
    }

    /**
     * 设置通用设置
     */
    @PutMapping("/general")
    public GeneralSetting setGeneralSetting(
            @CurrentAccountId Long accountId,
            @RequestBody GeneralSetting setting
    ) {
        return accountService.setGeneralSetting(accountId, setting);
    }

}
